package com.hjl.mybatis.servlet; /**
 * @author ServivE
 * @className ${NAME}
 * @description ${description}
 * @version 0.1
 * @date 2024/8/2 11:08
 * @since jdk11
 */

import com.hjl.mybatis.mapper.EmpMapper;
import com.hjl.mybatis.utils.SqlSessionFactoryUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DeleteEmpServlet", value = "/delEmp")
public class DeleteEmpServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int eid = Integer.parseInt(request.getParameter("eid"));
        int result = SqlSessionFactoryUtil.getSqlSession().getMapper(EmpMapper.class).deleteEmp(eid);
        response.sendRedirect("empInfo.html");
    }
}
